//
//  SAOpenPayVC.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/8/18.
//

#import "SAOpenPayVC.h"
#import "SABusinessInformationVC.h"
#import "HDWKWebVC.h"

@interface SAOpenPayVC ()

@property (nonatomic, strong) UIButton *openBtn;

@end

@implementation SAOpenPayVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)clickedOpenBtn {
    if (self.openBtn.isSelected != YES) {
        return;
    }
    SABusinessInformationVC *pushVC = [[SABusinessInformationVC alloc] init];
    [self.navigationController pushViewController:pushVC animated:YES];
}

-(void)clickedAgreeBtn {
    HDWKWebVC *pushVC = [[HDWKWebVC alloc] initWithTitle:@"衣点通用户开通扫码支付协议" AndUrl:@"http://ydtapi.kuaikuaifu.net/saas/ydt/payAgreement.html"];
    [self.navigationController pushViewController:pushVC animated:YES];
}

-(void)clickedReadBtn:(UIButton *)sender {
    sender.selected = !sender.isSelected;
    self.openBtn.selected = sender.isSelected;
}

-(void)initUI {
    [self setNavigationItemBackBBIAndTitle:@"扫码收款"];
    self.view.backgroundColor = kLineColor;
    [self setBgImage:nil];
    
    UILabel *titleLab = [[UILabel alloc] initWithFrame:SARectMake(0, StatusHeight + 15, kBaseScreenWidth, 16)];
    titleLab.text = @"主扫方式";
    titleLab.font = kBFont(15);
    titleLab.textColor = kBlackColor;
    titleLab.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:titleLab];
    
    UILabel *contentLab = [[UILabel alloc] initWithFrame:SARectMake(14, StatusHeight + 39, kBaseScreenWidth - 28, 32)];
    contentLab.text = @"用扫码枪扫描客户微信、支付宝、信用卡等支付无缝对接收银系统";
    contentLab.font = kFont(13);
    contentLab.textColor = kBlackColor;
    contentLab.numberOfLines = 2;
    contentLab.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:contentLab];
    
    UIImageView *payImageV = [[UIImageView alloc] initWithFrame:SARectMake(113, StatusHeight + 84, 149, 109)];
    payImageV.image = [UIImage imageNamed:@"pay_main"];
    [self.view addSubview:payImageV];

//    UIView *line = [[UIView alloc] initWithFrame:SARectMake(14, StatusHeight + 208, kBaseScreenWidth - 28, 0.5)];
//    line.backgroundColor = kColor(200, 200, 200, 1);
//    [self.view addSubview:line];
//
//    UILabel *IntroductionLab = [[UILabel alloc] initWithFrame:SARectMake(0, StatusHeight + 208, kBaseScreenWidth, 30)];
//    IntroductionLab.text = @"扫码收款简介";
//    IntroductionLab.font = kFont(14);
//    IntroductionLab.textColor = kBlackColor;
//    IntroductionLab.textAlignment = NSTextAlignmentCenter;
//    [self.view addSubview:IntroductionLab];
//
//    UIView *line2 = [[UIView alloc] initWithFrame:SARectMake(14, StatusHeight + 238, kBaseScreenWidth - 28, 0.5)];
//    line2.backgroundColor = kColor(200, 200, 200, 1);
//    [self.view addSubview:line2];
//
//    NSArray *arr = @[@"费用", @"优点", @"清算周期", @"安全有保障", @"使用方便"];
//    NSArray *arr2 = @[@"免费开通,无年费", @"支持微信、支付宝、\n花呗、信用卡付款", @"T+1工作日", @"乐刷支付", @"开通以后,收银结算时会有【扫码收款】结算方式"];
//    NSArray *arr3 = @[@"费用0.29%", @"账目清晰，便于统计，无缝对接收银系统", @"即当天收的款，第二个工作日自动转到你的银行卡，周五、周六、周日收款延迟到下周一到账，节假日收到的款到节后第一个工作日", @"上市公司，持有央行支付业务许可证，安全有保障", @"选择【扫码收款】结算，用扫码枪扫消费者微信或支付宝付款一维码，即可完成扫码收款"];
//
//    for (int i = 0; i < arr.count; i++) {
//        NSInteger height = 40;
//        NSInteger adjust = 0;
//        if (i == 2) {
//            height = 52;
//        }
//        if (i > 2) {
//            adjust = 12;
//        }
//        UILabel *lab1 = [[UILabel alloc] initWithFrame:SARectMake(17, StatusHeight + 238 + i * 40 + adjust, 67, height)];
//        lab1.text = arr[i];
//        lab1.font = kFont(10);
//        lab1.textColor = kBlackColor;
//        lab1.textAlignment = NSTextAlignmentLeft;
//        [self.view addSubview:lab1];
//
//        UILabel *lab2 = [[UILabel alloc] initWithFrame:SARectMake(85, StatusHeight + 238 + i * 40 + adjust, 101, height)];
//        lab2.text = arr2[i];
//        lab2.font = kFont(10);
//        lab2.textColor = kBlackColor;
//        lab2.numberOfLines = 0;
//        lab2.textAlignment = NSTextAlignmentLeft;
//        [self.view addSubview:lab2];
//
//        UILabel *lab3 = [[UILabel alloc] initWithFrame:SARectMake(196, StatusHeight + 238 + i * 40 + adjust, 161, height)];
//        lab3.text = arr3[i];
//        lab3.font = kFont(10);
//        lab3.textColor = kBlackColor;
//        lab3.numberOfLines = 0;
//        lab3.textAlignment = NSTextAlignmentLeft;
//        [self.view addSubview:lab3];
//
//        if (i > 1) {
//            adjust = 12;
//        }
//        UIView *line = [[UIView alloc] initWithFrame:SARectMake(14, StatusHeight + 238 + i * 40 + adjust + 40, kBaseScreenWidth - 28, 0.5)];
//        line.backgroundColor = kColor(200, 200, 200, 1);
//        [self.view addSubview:line];
//    }
//
//    UIView *line3 = [[UIView alloc] initWithFrame:SARectMake(14, StatusHeight + 208, 0.5, 242)];
//    line3.backgroundColor = kColor(200, 200, 200, 1);
//    [self.view addSubview:line3];
//
//    UIView *line4 = [[UIView alloc] initWithFrame:SARectMake(kBaseScreenWidth - 14, StatusHeight + 208, 0.5, 242)];
//    line4.backgroundColor = kColor(200, 200, 200, 1);
//    [self.view addSubview:line4];
//
//    UIView *line5 = [[UIView alloc] initWithFrame:SARectMake(80, StatusHeight + 238, 0.5, 212)];
//    line5.backgroundColor = kColor(200, 200, 200, 1);
//    [self.view addSubview:line5];
//
//    UIView *line6 = [[UIView alloc] initWithFrame:SARectMake(191, StatusHeight + 238, 0.5, 212)];
//    line6.backgroundColor = kColor(200, 200, 200, 1);
//    [self.view addSubview:line6];

    UIButton *openBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [openBtn setBackgroundImage:[UIImage imageNamed:@"button_gray_bg"] forState:UIControlStateNormal];
    [openBtn setBackgroundImage:[UIImage imageNamed:@"button_blue_bg"] forState:UIControlStateSelected];
    openBtn.frame = CGRectMake(kScaleNum(70), kScaleNum(StatusHeight + 230), kScaleNum(235), kScaleNum(35));
    [openBtn setTitle:@"开通支付" forState:UIControlStateNormal];
    openBtn.titleLabel.font = kFont(16);
    [openBtn addTarget:self action:@selector(clickedOpenBtn) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:openBtn];
    self.openBtn = openBtn;
    
    UIButton *readBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    readBtn.frame = CGRectMake(kScaleNum(53), kScaleNum(StatusHeight + 270), kScaleNum(135), kScaleNum(50));
    [readBtn setTitle:@"  我已经阅读并同意" forState:UIControlStateNormal];
    readBtn.titleLabel.font = kFont(14);
    [readBtn setTitleColor:kLightgGrayColor forState:UIControlStateNormal];
    [readBtn setImage:[UIImage imageNamed:@"pay_blueNoCheck"] forState:UIControlStateNormal];
    [readBtn setImage:[UIImage imageNamed:@"pay_blueCheck"] forState:UIControlStateSelected];
    readBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [readBtn addTarget:self action:@selector(clickedReadBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:readBtn];
    
    UIButton *agreeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    agreeBtn.frame = CGRectMake(kScaleNum(188), kScaleNum(StatusHeight + 270), kScaleNum(150), kScaleNum(50));
    [agreeBtn setTitle:@"《开通扫码支付协议》" forState:UIControlStateNormal];
    agreeBtn.titleLabel.font = kFont(14);
    [agreeBtn setTitleColor:kBuleColor forState:UIControlStateNormal];
    agreeBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [agreeBtn addTarget:self action:@selector(clickedAgreeBtn) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:agreeBtn];
}

@end
